package simulation;

import java.util.LinkedList;

/**
 * Authors: Kyle Martin
 * Purpose: Implements a queue.  Used in Simulation for takeoff and landing queues.
 * Version 1
 * Last modified: 11/15/11
 * Tested by:
 * Date tested:
 */
public class Queue 
{
	private LinkedList<Plane> list;
	
	//Useless Constructor
	public Queue()
	{
		list = new LinkedList<Plane>();
	}
	
	
	/**
	 * Authors: Kyle Martin
	 * Purpose: Adds a plane to the queue.
	 * Tested by: Ross Hadden
	 * Date tested: 11/15/11
	 */
	public void addPlaneToQueue(Plane object)
	{
		list.add(object);
	}
	/**
	 * Authors: Kyle Martin
	 * Purpose: Returns the head of the queue, without removing it.
	 * Tested by:
	 * Date tested:
	 */
	public Plane getFirstPlane()
	{
		int size = list.size();
		
		//Make sure object is in list
		if (size > 0)
		{
			return list.get(0);
		}
		else
		{
			return null;
		}
	}
	/**
	 * Authors: Kyle Martin
	 * Purpose: Returns the head of the queue and removes it.
	 * Tested by:
	 * Date tested:
	 */
	public Plane removeFirstObject()
	{
		int size = list.size();
		
		//Make sure object is in list
		if (size > 0)
		{
			return list.remove(0);
		}
		else
			return null;
	}
	
	/**
	 * Authors: Kyle Martin
	 * Purpose: Extra getters because the GUI needs to display the full queue.
	 * Tested by:
	 * Date tested:
	 */
	public int getSize()
	{
		return list.size();
	}
	public Plane getObjectAtIndex(int index)
	{
		return list.get(index);
	}
	
	//Returns the entire queue, needed for scoring and editing the schedule.
	public LinkedList<Plane> getAllPlanes(){
		return list;
	}
}
